import { queryGatewayResource } from '@/service/deliver';
import { useRequest } from 'ahooks';
import { Select, SelectProps } from 'antd';
import React, { useEffect } from 'react';
interface DataIdSelectProps extends SelectProps {
  env: string
}
const DataIdSelect = ({ env, ...props }: DataIdSelectProps) => {
  const { data, run } = useRequest(() => queryGatewayResource({ env }), {
    manual: true
  });
  useEffect(() => {
    run()
  }, [env])
  //   @ts-ignore
  const records = data ? data.records : []
  return (<Select
    options={records}
    {...props}
    fieldNames={{
      label: 'title',
      value: 'id'
    }}
  />)
}
export default DataIdSelect